package model

import (
	jsoniter "github.com/json-iterator/go"
	"strings"
)

type RegisterModel struct {
	RegisterObject *RegisterObject `json:"RegisterObject"`
}

type RegisterObject struct {
	DeviceID string `json:"DeviceID"`
	ProtocolVersion string `json:"ProtocolVersion,omitempty"`
}

func  BuildGat1400RegisterObj(deviceID string) *RegisterModel  {
	return &RegisterModel{
		RegisterObject:&RegisterObject{
			DeviceID : deviceID,
			ProtocolVersion:"2.0",
		},
	}
}

func (rm *RegisterModel)toString () string {
	bytes,_:= jsoniter.Marshal(rm)
	return string(bytes)
}
func (rm *RegisterModel) GetViewID() string {
	if rm == nil || rm.RegisterObject == nil {
		return ""
	}
	return strings.Trim(rm.RegisterObject.DeviceID, " ")
}
